<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - /usr/include/c++/4.3.2/bits/basic_string.tcc</title>
  <link rel="stylesheet" type="text/css" href="../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../../index.html">directory</a> - <a href="index.html">usr/include/c++/4.3.2/bits</a> - basic_string.tcc</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">16</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">0.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">0</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : // Components for manipulating sequences of characters -*- C++ -*-
<span class="lineNum">       2 </span>                : 
<span class="lineNum">       3 </span>                : // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
<span class="lineNum">       4 </span>                : // 2006, 2007
<span class="lineNum">       5 </span>                : // Free Software Foundation, Inc.
<span class="lineNum">       6 </span>                : //
<span class="lineNum">       7 </span>                : // This file is part of the GNU ISO C++ Library.  This library is free
<span class="lineNum">       8 </span>                : // software; you can redistribute it and/or modify it under the
<span class="lineNum">       9 </span>                : // terms of the GNU General Public License as published by the
<span class="lineNum">      10 </span>                : // Free Software Foundation; either version 2, or (at your option)
<span class="lineNum">      11 </span>                : // any later version.
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : // This library is distributed in the hope that it will be useful,
<span class="lineNum">      14 </span>                : // but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class="lineNum">      15 </span>                : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class="lineNum">      16 </span>                : // GNU General Public License for more details.
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // You should have received a copy of the GNU General Public License along
<span class="lineNum">      19 </span>                : // with this library; see the file COPYING.  If not, write to the Free
<span class="lineNum">      20 </span>                : // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
<span class="lineNum">      21 </span>                : // USA.
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : // As a special exception, you may use this file as part of a free software
<span class="lineNum">      24 </span>                : // library without restriction.  Specifically, if other files instantiate
<span class="lineNum">      25 </span>                : // templates or use macros or inline functions from this file, or you compile
<span class="lineNum">      26 </span>                : // this file and link it with other files to produce an executable, this
<span class="lineNum">      27 </span>                : // file does not by itself cause the resulting executable to be covered by
<span class="lineNum">      28 </span>                : // the GNU General Public License.  This exception does not however
<span class="lineNum">      29 </span>                : // invalidate any other reasons why the executable file might be covered by
<span class="lineNum">      30 </span>                : // the GNU General Public License.
<span class="lineNum">      31 </span>                : 
<span class="lineNum">      32 </span>                : /** @file basic_string.tcc
<span class="lineNum">      33 </span>                :  *  This is an internal header file, included by other library headers.
<span class="lineNum">      34 </span>                :  *  You should not attempt to use it directly.
<span class="lineNum">      35 </span>                :  */
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : //
<span class="lineNum">      38 </span>                : // ISO C++ 14882: 21  Strings library
<span class="lineNum">      39 </span>                : //
<span class="lineNum">      40 </span>                : 
<span class="lineNum">      41 </span>                : // Written by Jason Merrill based upon the specification by Takanori Adachi
<span class="lineNum">      42 </span>                : // in ANSI X3J16/94-0013R2.  Rewritten by Nathan Myers to ISO-14882.
<span class="lineNum">      43 </span>                : 
<span class="lineNum">      44 </span>                : #ifndef _BASIC_STRING_TCC
<span class="lineNum">      45 </span>                : #define _BASIC_STRING_TCC 1
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span>                : #pragma GCC system_header
<span class="lineNum">      48 </span>                : 
<span class="lineNum">      49 </span>                : #include &lt;cxxabi-forced.h&gt;
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span>                : _GLIBCXX_BEGIN_NAMESPACE(std)
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">      54 </span>                :     const typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">      55 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">      56 </span>                :     _Rep::_S_max_size = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
<span class="lineNum">      57 </span>                : 
<span class="lineNum">      58 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">      59 </span>                :     const _CharT
<span class="lineNum">      60 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">      61 </span>                :     _Rep::_S_terminal = _CharT();
<span class="lineNum">      62 </span>                : 
<span class="lineNum">      63 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">      64 </span>                :     const typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">      65 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::npos;
<span class="lineNum">      66 </span>                : 
<span class="lineNum">      67 </span>                :   // Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
<span class="lineNum">      68 </span>                :   // at static init time (before static ctors are run).
<span class="lineNum">      69 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">      70 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">      71 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::_Rep::_S_empty_rep_storage[
<span class="lineNum">      72 </span>                :     (sizeof(_Rep_base) + sizeof(_CharT) + sizeof(size_type) - 1) /
<span class="lineNum">      73 </span>                :       sizeof(size_type)];
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                :   // NB: This is the special case for Input Iterators, used in
<span class="lineNum">      76 </span>                :   // istreambuf_iterators, etc.
<span class="lineNum">      77 </span>                :   // Input Iterators have a cost structure very different from
<span class="lineNum">      78 </span>                :   // pointers, calling for a different coding style.
<span class="lineNum">      79 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">      80 </span>                :     template&lt;typename _InIterator&gt;
<span class="lineNum">      81 </span>                :       _CharT*
<span class="lineNum">      82 </span>                :       basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">      83 </span>                :       _S_construct(_InIterator __beg, _InIterator __end, const _Alloc&amp; __a,
<span class="lineNum">      84 </span>                :                    input_iterator_tag)
<span class="lineNum">      85 </span>                :       {
<span class="lineNum">      86 </span>                : #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
<span class="lineNum">      87 </span>                :         if (__beg == __end &amp;&amp; __a == _Alloc())
<span class="lineNum">      88 </span>                :           return _S_empty_rep()._M_refdata();
<span class="lineNum">      89 </span>                : #endif
<span class="lineNum">      90 </span>                :         // Avoid reallocation for common case.
<span class="lineNum">      91 </span>                :         _CharT __buf[128];
<span class="lineNum">      92 </span>                :         size_type __len = 0;
<span class="lineNum">      93 </span>                :         while (__beg != __end &amp;&amp; __len &lt; sizeof(__buf) / sizeof(_CharT))
<span class="lineNum">      94 </span>                :           {
<span class="lineNum">      95 </span>                :             __buf[__len++] = *__beg;
<span class="lineNum">      96 </span>                :             ++__beg;
<span class="lineNum">      97 </span>                :           }
<span class="lineNum">      98 </span>                :         _Rep* __r = _Rep::_S_create(__len, size_type(0), __a);
<span class="lineNum">      99 </span>                :         _M_copy(__r-&gt;_M_refdata(), __buf, __len);
<span class="lineNum">     100 </span>                :         try
<span class="lineNum">     101 </span>                :           {
<span class="lineNum">     102 </span>                :             while (__beg != __end)
<span class="lineNum">     103 </span>                :               {
<span class="lineNum">     104 </span>                :                 if (__len == __r-&gt;_M_capacity)
<span class="lineNum">     105 </span>                :                   {
<span class="lineNum">     106 </span>                :                     // Allocate more space.
<span class="lineNum">     107 </span>                :                     _Rep* __another = _Rep::_S_create(__len + 1, __len, __a);
<span class="lineNum">     108 </span>                :                     _M_copy(__another-&gt;_M_refdata(), __r-&gt;_M_refdata(), __len);
<span class="lineNum">     109 </span>                :                     __r-&gt;_M_destroy(__a);
<span class="lineNum">     110 </span>                :                     __r = __another;
<span class="lineNum">     111 </span>                :                   }
<span class="lineNum">     112 </span>                :                 __r-&gt;_M_refdata()[__len++] = *__beg;
<span class="lineNum">     113 </span>                :                 ++__beg;
<span class="lineNum">     114 </span>                :               }
<span class="lineNum">     115 </span>                :           }
<span class="lineNum">     116 </span>                :         catch(...)
<span class="lineNum">     117 </span>                :           {
<span class="lineNum">     118 </span>                :             __r-&gt;_M_destroy(__a);
<span class="lineNum">     119 </span>                :             __throw_exception_again;
<span class="lineNum">     120 </span>                :           }
<span class="lineNum">     121 </span>                :         __r-&gt;_M_set_length_and_sharable(__len);
<span class="lineNum">     122 </span>                :         return __r-&gt;_M_refdata();
<span class="lineNum">     123 </span>                :       }
<span class="lineNum">     124 </span>                : 
<span class="lineNum">     125 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     126 </span>                :     template &lt;typename _InIterator&gt;
<span class="lineNum">     127 </span>                :       _CharT*
<span class="lineNum">     128 </span>                :       basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     129 </span>                :       _S_construct(_InIterator __beg, _InIterator __end, const _Alloc&amp; __a,
<span class="lineNum">     130 </span><span class="lineNoCov">              0 :                    forward_iterator_tag)</span>
<span class="lineNum">     131 </span>                :       {
<span class="lineNum">     132 </span>                : #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
<span class="lineNum">     133 </span><span class="lineNoCov">              0 :         if (__beg == __end &amp;&amp; __a == _Alloc())</span>
<span class="lineNum">     134 </span><span class="lineNoCov">              0 :           return _S_empty_rep()._M_refdata();</span>
<span class="lineNum">     135 </span>                : #endif
<span class="lineNum">     136 </span>                :         // NB: Not required, but considered best practice.
<span class="lineNum">     137 </span><span class="lineNoCov">              0 :         if (__builtin_expect(__gnu_cxx::__is_null_pointer(__beg)</span>
<span class="lineNum">     138 </span>                :                              &amp;&amp; __beg != __end, 0))
<span class="lineNum">     139 </span><span class="lineNoCov">              0 :           __throw_logic_error(__N(&quot;basic_string::_S_construct NULL not valid&quot;));</span>
<span class="lineNum">     140 </span>                : 
<span class="lineNum">     141 </span>                :         const size_type __dnew = static_cast&lt;size_type&gt;(std::distance(__beg,
<span class="lineNum">     142 </span><span class="lineNoCov">              0 :                                                                       __end));</span>
<span class="lineNum">     143 </span>                :         // Check for out_of_range and length_error exceptions.
<span class="lineNum">     144 </span><span class="lineNoCov">              0 :         _Rep* __r = _Rep::_S_create(__dnew, size_type(0), __a);</span>
<span class="lineNum">     145 </span>                :         try
<span class="lineNum">     146 </span><span class="lineNoCov">              0 :           { _S_copy_chars(__r-&gt;_M_refdata(), __beg, __end); }</span>
<span class="lineNum">     147 </span><span class="lineNoCov">              0 :         catch(...)</span>
<span class="lineNum">     148 </span>                :           {
<span class="lineNum">     149 </span><span class="lineNoCov">              0 :             __r-&gt;_M_destroy(__a);</span>
<span class="lineNum">     150 </span><span class="lineNoCov">              0 :             __throw_exception_again;</span>
<span class="lineNum">     151 </span>                :           }
<span class="lineNum">     152 </span><span class="lineNoCov">              0 :         __r-&gt;_M_set_length_and_sharable(__dnew);</span>
<span class="lineNum">     153 </span><span class="lineNoCov">              0 :         return __r-&gt;_M_refdata();</span>
<span class="lineNum">     154 </span>                :       }
<span class="lineNum">     155 </span>                : 
<span class="lineNum">     156 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     157 </span>                :     _CharT*
<span class="lineNum">     158 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     159 </span>                :     _S_construct(size_type __n, _CharT __c, const _Alloc&amp; __a)
<span class="lineNum">     160 </span>                :     {
<span class="lineNum">     161 </span>                : #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
<span class="lineNum">     162 </span>                :       if (__n == 0 &amp;&amp; __a == _Alloc())
<span class="lineNum">     163 </span>                :         return _S_empty_rep()._M_refdata();
<span class="lineNum">     164 </span>                : #endif
<span class="lineNum">     165 </span>                :       // Check for out_of_range and length_error exceptions.
<span class="lineNum">     166 </span>                :       _Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
<span class="lineNum">     167 </span>                :       if (__n)
<span class="lineNum">     168 </span>                :         _M_assign(__r-&gt;_M_refdata(), __n, __c);
<span class="lineNum">     169 </span>                : 
<span class="lineNum">     170 </span>                :       __r-&gt;_M_set_length_and_sharable(__n);
<span class="lineNum">     171 </span>                :       return __r-&gt;_M_refdata();
<span class="lineNum">     172 </span>                :     }
<span class="lineNum">     173 </span>                : 
<span class="lineNum">     174 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     175 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     176 </span>                :     basic_string(const basic_string&amp; __str)
<span class="lineNum">     177 </span>                :     : _M_dataplus(__str._M_rep()-&gt;_M_grab(_Alloc(__str.get_allocator()),
<span class="lineNum">     178 </span>                :                                           __str.get_allocator()),
<span class="lineNum">     179 </span>                :                   __str.get_allocator())
<span class="lineNum">     180 </span>                :     { }
<span class="lineNum">     181 </span>                : 
<span class="lineNum">     182 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     183 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     184 </span>                :     basic_string(const _Alloc&amp; __a)
<span class="lineNum">     185 </span>                :     : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
<span class="lineNum">     186 </span>                :     { }
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     189 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     190 </span>                :     basic_string(const basic_string&amp; __str, size_type __pos, size_type __n)
<span class="lineNum">     191 </span>                :     : _M_dataplus(_S_construct(__str._M_data()
<span class="lineNum">     192 </span>                :                                + __str._M_check(__pos,
<span class="lineNum">     193 </span>                :                                                 &quot;basic_string::basic_string&quot;),
<span class="lineNum">     194 </span>                :                                __str._M_data() + __str._M_limit(__pos, __n)
<span class="lineNum">     195 </span>                :                                + __pos, _Alloc()), _Alloc())
<span class="lineNum">     196 </span>                :     { }
<span class="lineNum">     197 </span>                : 
<span class="lineNum">     198 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     199 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     200 </span>                :     basic_string(const basic_string&amp; __str, size_type __pos,
<span class="lineNum">     201 </span>                :                  size_type __n, const _Alloc&amp; __a)
<span class="lineNum">     202 </span>                :     : _M_dataplus(_S_construct(__str._M_data()
<span class="lineNum">     203 </span>                :                                + __str._M_check(__pos,
<span class="lineNum">     204 </span>                :                                                 &quot;basic_string::basic_string&quot;),
<span class="lineNum">     205 </span>                :                                __str._M_data() + __str._M_limit(__pos, __n)
<span class="lineNum">     206 </span>                :                                + __pos, __a), __a)
<span class="lineNum">     207 </span>                :     { }
<span class="lineNum">     208 </span>                : 
<span class="lineNum">     209 </span>                :   // TBD: DPG annotate
<span class="lineNum">     210 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     211 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     212 </span>                :     basic_string(const _CharT* __s, size_type __n, const _Alloc&amp; __a)
<span class="lineNum">     213 </span>                :     : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
<span class="lineNum">     214 </span>                :     { }
<span class="lineNum">     215 </span>                : 
<span class="lineNum">     216 </span>                :   // TBD: DPG annotate
<span class="lineNum">     217 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     218 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     219 </span>                :     basic_string(const _CharT* __s, const _Alloc&amp; __a)
<span class="lineNum">     220 </span>                :     : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
<span class="lineNum">     221 </span>                :                                __s + npos, __a), __a)
<span class="lineNum">     222 </span>                :     { }
<span class="lineNum">     223 </span>                : 
<span class="lineNum">     224 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     225 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     226 </span>                :     basic_string(size_type __n, _CharT __c, const _Alloc&amp; __a)
<span class="lineNum">     227 </span>                :     : _M_dataplus(_S_construct(__n, __c, __a), __a)
<span class="lineNum">     228 </span>                :     { }
<span class="lineNum">     229 </span>                : 
<span class="lineNum">     230 </span>                :   // TBD: DPG annotate
<span class="lineNum">     231 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     232 </span>                :     template&lt;typename _InputIterator&gt;
<span class="lineNum">     233 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     234 </span><span class="lineNoCov">              0 :     basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc&amp; __a)</span>
<span class="lineNum">     235 </span><span class="lineNoCov">              0 :     : _M_dataplus(_S_construct(__beg, __end, __a), __a)</span>
<span class="lineNum">     236 </span><span class="lineNoCov">              0 :     { }</span>
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     239 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     240 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     241 </span>                :     assign(const basic_string&amp; __str)
<span class="lineNum">     242 </span>                :     {
<span class="lineNum">     243 </span>                :       if (_M_rep() != __str._M_rep())
<span class="lineNum">     244 </span>                :         {
<span class="lineNum">     245 </span>                :           // XXX MT
<span class="lineNum">     246 </span>                :           const allocator_type __a = this-&gt;get_allocator();
<span class="lineNum">     247 </span>                :           _CharT* __tmp = __str._M_rep()-&gt;_M_grab(__a, __str.get_allocator());
<span class="lineNum">     248 </span>                :           _M_rep()-&gt;_M_dispose(__a);
<span class="lineNum">     249 </span>                :           _M_data(__tmp);
<span class="lineNum">     250 </span>                :         }
<span class="lineNum">     251 </span>                :       return *this;
<span class="lineNum">     252 </span>                :     }
<span class="lineNum">     253 </span>                : 
<span class="lineNum">     254 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     255 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     256 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     257 </span>                :     assign(const _CharT* __s, size_type __n)
<span class="lineNum">     258 </span>                :     {
<span class="lineNum">     259 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     260 </span>                :       _M_check_length(this-&gt;size(), __n, &quot;basic_string::assign&quot;);
<span class="lineNum">     261 </span>                :       if (_M_disjunct(__s) || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     262 </span>                :         return _M_replace_safe(size_type(0), this-&gt;size(), __s, __n);
<span class="lineNum">     263 </span>                :       else
<span class="lineNum">     264 </span>                :         {
<span class="lineNum">     265 </span>                :           // Work in-place.
<span class="lineNum">     266 </span>                :           const size_type __pos = __s - _M_data();
<span class="lineNum">     267 </span>                :           if (__pos &gt;= __n)
<span class="lineNum">     268 </span>                :             _M_copy(_M_data(), __s, __n);
<span class="lineNum">     269 </span>                :           else if (__pos)
<span class="lineNum">     270 </span>                :             _M_move(_M_data(), __s, __n);
<span class="lineNum">     271 </span>                :           _M_rep()-&gt;_M_set_length_and_sharable(__n);
<span class="lineNum">     272 </span>                :           return *this;
<span class="lineNum">     273 </span>                :         }
<span class="lineNum">     274 </span>                :      }
<span class="lineNum">     275 </span>                : 
<span class="lineNum">     276 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     277 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     278 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     279 </span>                :     append(size_type __n, _CharT __c)
<span class="lineNum">     280 </span>                :     {
<span class="lineNum">     281 </span>                :       if (__n)
<span class="lineNum">     282 </span>                :         {
<span class="lineNum">     283 </span>                :           _M_check_length(size_type(0), __n, &quot;basic_string::append&quot;);   
<span class="lineNum">     284 </span>                :           const size_type __len = __n + this-&gt;size();
<span class="lineNum">     285 </span>                :           if (__len &gt; this-&gt;capacity() || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     286 </span>                :             this-&gt;reserve(__len);
<span class="lineNum">     287 </span>                :           _M_assign(_M_data() + this-&gt;size(), __n, __c);
<span class="lineNum">     288 </span>                :           _M_rep()-&gt;_M_set_length_and_sharable(__len);
<span class="lineNum">     289 </span>                :         }
<span class="lineNum">     290 </span>                :       return *this;
<span class="lineNum">     291 </span>                :     }
<span class="lineNum">     292 </span>                : 
<span class="lineNum">     293 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     294 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     295 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     296 </span>                :     append(const _CharT* __s, size_type __n)
<span class="lineNum">     297 </span>                :     {
<span class="lineNum">     298 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     299 </span>                :       if (__n)
<span class="lineNum">     300 </span>                :         {
<span class="lineNum">     301 </span>                :           _M_check_length(size_type(0), __n, &quot;basic_string::append&quot;);
<span class="lineNum">     302 </span>                :           const size_type __len = __n + this-&gt;size();
<span class="lineNum">     303 </span>                :           if (__len &gt; this-&gt;capacity() || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     304 </span>                :             {
<span class="lineNum">     305 </span>                :               if (_M_disjunct(__s))
<span class="lineNum">     306 </span>                :                 this-&gt;reserve(__len);
<span class="lineNum">     307 </span>                :               else
<span class="lineNum">     308 </span>                :                 {
<span class="lineNum">     309 </span>                :                   const size_type __off = __s - _M_data();
<span class="lineNum">     310 </span>                :                   this-&gt;reserve(__len);
<span class="lineNum">     311 </span>                :                   __s = _M_data() + __off;
<span class="lineNum">     312 </span>                :                 }
<span class="lineNum">     313 </span>                :             }
<span class="lineNum">     314 </span>                :           _M_copy(_M_data() + this-&gt;size(), __s, __n);
<span class="lineNum">     315 </span>                :           _M_rep()-&gt;_M_set_length_and_sharable(__len);
<span class="lineNum">     316 </span>                :         }
<span class="lineNum">     317 </span>                :       return *this;
<span class="lineNum">     318 </span>                :     }
<span class="lineNum">     319 </span>                : 
<span class="lineNum">     320 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     321 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     322 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     323 </span>                :     append(const basic_string&amp; __str)
<span class="lineNum">     324 </span>                :     {
<span class="lineNum">     325 </span>                :       const size_type __size = __str.size();
<span class="lineNum">     326 </span>                :       if (__size)
<span class="lineNum">     327 </span>                :         {
<span class="lineNum">     328 </span>                :           const size_type __len = __size + this-&gt;size();
<span class="lineNum">     329 </span>                :           if (__len &gt; this-&gt;capacity() || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     330 </span>                :             this-&gt;reserve(__len);
<span class="lineNum">     331 </span>                :           _M_copy(_M_data() + this-&gt;size(), __str._M_data(), __size);
<span class="lineNum">     332 </span>                :           _M_rep()-&gt;_M_set_length_and_sharable(__len);
<span class="lineNum">     333 </span>                :         }
<span class="lineNum">     334 </span>                :       return *this;
<span class="lineNum">     335 </span>                :     }    
<span class="lineNum">     336 </span>                : 
<span class="lineNum">     337 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     338 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     339 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     340 </span>                :     append(const basic_string&amp; __str, size_type __pos, size_type __n)
<span class="lineNum">     341 </span>                :     {
<span class="lineNum">     342 </span>                :       __str._M_check(__pos, &quot;basic_string::append&quot;);
<span class="lineNum">     343 </span>                :       __n = __str._M_limit(__pos, __n);
<span class="lineNum">     344 </span>                :       if (__n)
<span class="lineNum">     345 </span>                :         {
<span class="lineNum">     346 </span>                :           const size_type __len = __n + this-&gt;size();
<span class="lineNum">     347 </span>                :           if (__len &gt; this-&gt;capacity() || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     348 </span>                :             this-&gt;reserve(__len);
<span class="lineNum">     349 </span>                :           _M_copy(_M_data() + this-&gt;size(), __str._M_data() + __pos, __n);
<span class="lineNum">     350 </span>                :           _M_rep()-&gt;_M_set_length_and_sharable(__len);         
<span class="lineNum">     351 </span>                :         }
<span class="lineNum">     352 </span>                :       return *this;
<span class="lineNum">     353 </span>                :     }
<span class="lineNum">     354 </span>                : 
<span class="lineNum">     355 </span>                :    template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     356 </span>                :      basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     357 </span>                :      basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     358 </span>                :      insert(size_type __pos, const _CharT* __s, size_type __n)
<span class="lineNum">     359 </span>                :      {
<span class="lineNum">     360 </span>                :        __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     361 </span>                :        _M_check(__pos, &quot;basic_string::insert&quot;);
<span class="lineNum">     362 </span>                :        _M_check_length(size_type(0), __n, &quot;basic_string::insert&quot;);
<span class="lineNum">     363 </span>                :        if (_M_disjunct(__s) || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     364 </span>                :          return _M_replace_safe(__pos, size_type(0), __s, __n);
<span class="lineNum">     365 </span>                :        else
<span class="lineNum">     366 </span>                :          {
<span class="lineNum">     367 </span>                :            // Work in-place.
<span class="lineNum">     368 </span>                :            const size_type __off = __s - _M_data();
<span class="lineNum">     369 </span>                :            _M_mutate(__pos, 0, __n);
<span class="lineNum">     370 </span>                :            __s = _M_data() + __off;
<span class="lineNum">     371 </span>                :            _CharT* __p = _M_data() + __pos;
<span class="lineNum">     372 </span>                :            if (__s  + __n &lt;= __p)
<span class="lineNum">     373 </span>                :              _M_copy(__p, __s, __n);
<span class="lineNum">     374 </span>                :            else if (__s &gt;= __p)
<span class="lineNum">     375 </span>                :              _M_copy(__p, __s + __n, __n);
<span class="lineNum">     376 </span>                :            else
<span class="lineNum">     377 </span>                :              {
<span class="lineNum">     378 </span>                :                const size_type __nleft = __p - __s;
<span class="lineNum">     379 </span>                :                _M_copy(__p, __s, __nleft);
<span class="lineNum">     380 </span>                :                _M_copy(__p + __nleft, __p + __n, __n - __nleft);
<span class="lineNum">     381 </span>                :              }
<span class="lineNum">     382 </span>                :            return *this;
<span class="lineNum">     383 </span>                :          }
<span class="lineNum">     384 </span>                :      }
<span class="lineNum">     385 </span>                : 
<span class="lineNum">     386 </span>                :    template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     387 </span>                :      basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     388 </span>                :      basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     389 </span>                :      replace(size_type __pos, size_type __n1, const _CharT* __s,
<span class="lineNum">     390 </span>                :              size_type __n2)
<span class="lineNum">     391 </span>                :      {
<span class="lineNum">     392 </span>                :        __glibcxx_requires_string_len(__s, __n2);
<span class="lineNum">     393 </span>                :        _M_check(__pos, &quot;basic_string::replace&quot;);
<span class="lineNum">     394 </span>                :        __n1 = _M_limit(__pos, __n1);
<span class="lineNum">     395 </span>                :        _M_check_length(__n1, __n2, &quot;basic_string::replace&quot;);
<span class="lineNum">     396 </span>                :        bool __left;
<span class="lineNum">     397 </span>                :        if (_M_disjunct(__s) || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     398 </span>                :          return _M_replace_safe(__pos, __n1, __s, __n2);
<span class="lineNum">     399 </span>                :        else if ((__left = __s + __n2 &lt;= _M_data() + __pos)
<span class="lineNum">     400 </span>                :                 || _M_data() + __pos + __n1 &lt;= __s)
<span class="lineNum">     401 </span>                :          {
<span class="lineNum">     402 </span>                :            // Work in-place: non-overlapping case.
<span class="lineNum">     403 </span>                :            size_type __off = __s - _M_data();
<span class="lineNum">     404 </span>                :            __left ? __off : (__off += __n2 - __n1);
<span class="lineNum">     405 </span>                :            _M_mutate(__pos, __n1, __n2);
<span class="lineNum">     406 </span>                :            _M_copy(_M_data() + __pos, _M_data() + __off, __n2);
<span class="lineNum">     407 </span>                :            return *this;
<span class="lineNum">     408 </span>                :          }
<span class="lineNum">     409 </span>                :        else
<span class="lineNum">     410 </span>                :          {
<span class="lineNum">     411 </span>                :            // Todo: overlapping case.
<span class="lineNum">     412 </span>                :            const basic_string __tmp(__s, __n2);
<span class="lineNum">     413 </span>                :            return _M_replace_safe(__pos, __n1, __tmp._M_data(), __n2);
<span class="lineNum">     414 </span>                :          }
<span class="lineNum">     415 </span>                :      }
<span class="lineNum">     416 </span>                : 
<span class="lineNum">     417 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     418 </span>                :     void
<span class="lineNum">     419 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::_Rep::
<span class="lineNum">     420 </span>                :     _M_destroy(const _Alloc&amp; __a) throw ()
<span class="lineNum">     421 </span>                :     {
<span class="lineNum">     422 </span>                :       const size_type __size = sizeof(_Rep_base) +
<span class="lineNum">     423 </span>                :                                (this-&gt;_M_capacity + 1) * sizeof(_CharT);
<span class="lineNum">     424 </span>                :       _Raw_bytes_alloc(__a).deallocate(reinterpret_cast&lt;char*&gt;(this), __size);
<span class="lineNum">     425 </span>                :     }
<span class="lineNum">     426 </span>                : 
<span class="lineNum">     427 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     428 </span>                :     void
<span class="lineNum">     429 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     430 </span>                :     _M_leak_hard()
<span class="lineNum">     431 </span>                :     {
<span class="lineNum">     432 </span>                : #ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
<span class="lineNum">     433 </span>                :       if (_M_rep() == &amp;_S_empty_rep())
<span class="lineNum">     434 </span>                :         return;
<span class="lineNum">     435 </span>                : #endif
<span class="lineNum">     436 </span>                :       if (_M_rep()-&gt;_M_is_shared())
<span class="lineNum">     437 </span>                :         _M_mutate(0, 0, 0);
<span class="lineNum">     438 </span>                :       _M_rep()-&gt;_M_set_leaked();
<span class="lineNum">     439 </span>                :     }
<span class="lineNum">     440 </span>                : 
<span class="lineNum">     441 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     442 </span>                :     void
<span class="lineNum">     443 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     444 </span>                :     _M_mutate(size_type __pos, size_type __len1, size_type __len2)
<span class="lineNum">     445 </span>                :     {
<span class="lineNum">     446 </span>                :       const size_type __old_size = this-&gt;size();
<span class="lineNum">     447 </span>                :       const size_type __new_size = __old_size + __len2 - __len1;
<span class="lineNum">     448 </span>                :       const size_type __how_much = __old_size - __pos - __len1;
<span class="lineNum">     449 </span>                : 
<span class="lineNum">     450 </span>                :       if (__new_size &gt; this-&gt;capacity() || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     451 </span>                :         {
<span class="lineNum">     452 </span>                :           // Must reallocate.
<span class="lineNum">     453 </span>                :           const allocator_type __a = get_allocator();
<span class="lineNum">     454 </span>                :           _Rep* __r = _Rep::_S_create(__new_size, this-&gt;capacity(), __a);
<span class="lineNum">     455 </span>                : 
<span class="lineNum">     456 </span>                :           if (__pos)
<span class="lineNum">     457 </span>                :             _M_copy(__r-&gt;_M_refdata(), _M_data(), __pos);
<span class="lineNum">     458 </span>                :           if (__how_much)
<span class="lineNum">     459 </span>                :             _M_copy(__r-&gt;_M_refdata() + __pos + __len2,
<span class="lineNum">     460 </span>                :                     _M_data() + __pos + __len1, __how_much);
<span class="lineNum">     461 </span>                : 
<span class="lineNum">     462 </span>                :           _M_rep()-&gt;_M_dispose(__a);
<span class="lineNum">     463 </span>                :           _M_data(__r-&gt;_M_refdata());
<span class="lineNum">     464 </span>                :         }
<span class="lineNum">     465 </span>                :       else if (__how_much &amp;&amp; __len1 != __len2)
<span class="lineNum">     466 </span>                :         {
<span class="lineNum">     467 </span>                :           // Work in-place.
<span class="lineNum">     468 </span>                :           _M_move(_M_data() + __pos + __len2,
<span class="lineNum">     469 </span>                :                   _M_data() + __pos + __len1, __how_much);
<span class="lineNum">     470 </span>                :         }
<span class="lineNum">     471 </span>                :       _M_rep()-&gt;_M_set_length_and_sharable(__new_size);
<span class="lineNum">     472 </span>                :     }
<span class="lineNum">     473 </span>                : 
<span class="lineNum">     474 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     475 </span>                :     void
<span class="lineNum">     476 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     477 </span>                :     reserve(size_type __res)
<span class="lineNum">     478 </span>                :     {
<span class="lineNum">     479 </span>                :       if (__res != this-&gt;capacity() || _M_rep()-&gt;_M_is_shared())
<span class="lineNum">     480 </span>                :         {
<span class="lineNum">     481 </span>                :           // Make sure we don't shrink below the current size
<span class="lineNum">     482 </span>                :           if (__res &lt; this-&gt;size())
<span class="lineNum">     483 </span>                :             __res = this-&gt;size();
<span class="lineNum">     484 </span>                :           const allocator_type __a = get_allocator();
<span class="lineNum">     485 </span>                :           _CharT* __tmp = _M_rep()-&gt;_M_clone(__a, __res - this-&gt;size());
<span class="lineNum">     486 </span>                :           _M_rep()-&gt;_M_dispose(__a);
<span class="lineNum">     487 </span>                :           _M_data(__tmp);
<span class="lineNum">     488 </span>                :         }
<span class="lineNum">     489 </span>                :     }
<span class="lineNum">     490 </span>                : 
<span class="lineNum">     491 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     492 </span>                :     void
<span class="lineNum">     493 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     494 </span>                :     swap(basic_string&amp; __s)
<span class="lineNum">     495 </span>                :     {
<span class="lineNum">     496 </span>                :       if (_M_rep()-&gt;_M_is_leaked())
<span class="lineNum">     497 </span>                :         _M_rep()-&gt;_M_set_sharable();
<span class="lineNum">     498 </span>                :       if (__s._M_rep()-&gt;_M_is_leaked())
<span class="lineNum">     499 </span>                :         __s._M_rep()-&gt;_M_set_sharable();
<span class="lineNum">     500 </span>                :       if (this-&gt;get_allocator() == __s.get_allocator())
<span class="lineNum">     501 </span>                :         {
<span class="lineNum">     502 </span>                :           _CharT* __tmp = _M_data();
<span class="lineNum">     503 </span>                :           _M_data(__s._M_data());
<span class="lineNum">     504 </span>                :           __s._M_data(__tmp);
<span class="lineNum">     505 </span>                :         }
<span class="lineNum">     506 </span>                :       // The code below can usually be optimized away.
<span class="lineNum">     507 </span>                :       else
<span class="lineNum">     508 </span>                :         {
<span class="lineNum">     509 </span>                :           const basic_string __tmp1(_M_ibegin(), _M_iend(),
<span class="lineNum">     510 </span>                :                                     __s.get_allocator());
<span class="lineNum">     511 </span>                :           const basic_string __tmp2(__s._M_ibegin(), __s._M_iend(),
<span class="lineNum">     512 </span>                :                                     this-&gt;get_allocator());
<span class="lineNum">     513 </span>                :           *this = __tmp2;
<span class="lineNum">     514 </span>                :           __s = __tmp1;
<span class="lineNum">     515 </span>                :         }
<span class="lineNum">     516 </span>                :     }
<span class="lineNum">     517 </span>                : 
<span class="lineNum">     518 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     519 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::_Rep*
<span class="lineNum">     520 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::_Rep::
<span class="lineNum">     521 </span>                :     _S_create(size_type __capacity, size_type __old_capacity,
<span class="lineNum">     522 </span>                :               const _Alloc&amp; __alloc)
<span class="lineNum">     523 </span>                :     {
<span class="lineNum">     524 </span>                :       // _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">     525 </span>                :       // 83.  String::npos vs. string::max_size()
<span class="lineNum">     526 </span>                :       if (__capacity &gt; _S_max_size)
<span class="lineNum">     527 </span>                :         __throw_length_error(__N(&quot;basic_string::_S_create&quot;));
<span class="lineNum">     528 </span>                : 
<span class="lineNum">     529 </span>                :       // The standard places no restriction on allocating more memory
<span class="lineNum">     530 </span>                :       // than is strictly needed within this layer at the moment or as
<span class="lineNum">     531 </span>                :       // requested by an explicit application call to reserve().
<span class="lineNum">     532 </span>                : 
<span class="lineNum">     533 </span>                :       // Many malloc implementations perform quite poorly when an
<span class="lineNum">     534 </span>                :       // application attempts to allocate memory in a stepwise fashion
<span class="lineNum">     535 </span>                :       // growing each allocation size by only 1 char.  Additionally,
<span class="lineNum">     536 </span>                :       // it makes little sense to allocate less linear memory than the
<span class="lineNum">     537 </span>                :       // natural blocking size of the malloc implementation.
<span class="lineNum">     538 </span>                :       // Unfortunately, we would need a somewhat low-level calculation
<span class="lineNum">     539 </span>                :       // with tuned parameters to get this perfect for any particular
<span class="lineNum">     540 </span>                :       // malloc implementation.  Fortunately, generalizations about
<span class="lineNum">     541 </span>                :       // common features seen among implementations seems to suffice.
<span class="lineNum">     542 </span>                : 
<span class="lineNum">     543 </span>                :       // __pagesize need not match the actual VM page size for good
<span class="lineNum">     544 </span>                :       // results in practice, thus we pick a common value on the low
<span class="lineNum">     545 </span>                :       // side.  __malloc_header_size is an estimate of the amount of
<span class="lineNum">     546 </span>                :       // overhead per memory allocation (in practice seen N * sizeof
<span class="lineNum">     547 </span>                :       // (void*) where N is 0, 2 or 4).  According to folklore,
<span class="lineNum">     548 </span>                :       // picking this value on the high side is better than
<span class="lineNum">     549 </span>                :       // low-balling it (especially when this algorithm is used with
<span class="lineNum">     550 </span>                :       // malloc implementations that allocate memory blocks rounded up
<span class="lineNum">     551 </span>                :       // to a size which is a power of 2).
<span class="lineNum">     552 </span>                :       const size_type __pagesize = 4096;
<span class="lineNum">     553 </span>                :       const size_type __malloc_header_size = 4 * sizeof(void*);
<span class="lineNum">     554 </span>                : 
<span class="lineNum">     555 </span>                :       // The below implements an exponential growth policy, necessary to
<span class="lineNum">     556 </span>                :       // meet amortized linear time requirements of the library: see
<span class="lineNum">     557 </span>                :       // http://gcc.gnu.org/ml/libstdc++/2001-07/msg00085.html.
<span class="lineNum">     558 </span>                :       // It's active for allocations requiring an amount of memory above
<span class="lineNum">     559 </span>                :       // system pagesize. This is consistent with the requirements of the
<span class="lineNum">     560 </span>                :       // standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html
<span class="lineNum">     561 </span>                :       if (__capacity &gt; __old_capacity &amp;&amp; __capacity &lt; 2 * __old_capacity)
<span class="lineNum">     562 </span>                :         __capacity = 2 * __old_capacity;
<span class="lineNum">     563 </span>                : 
<span class="lineNum">     564 </span>                :       // NB: Need an array of char_type[__capacity], plus a terminating
<span class="lineNum">     565 </span>                :       // null char_type() element, plus enough for the _Rep data structure.
<span class="lineNum">     566 </span>                :       // Whew. Seemingly so needy, yet so elemental.
<span class="lineNum">     567 </span>                :       size_type __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
<span class="lineNum">     568 </span>                : 
<span class="lineNum">     569 </span>                :       const size_type __adj_size = __size + __malloc_header_size;
<span class="lineNum">     570 </span>                :       if (__adj_size &gt; __pagesize &amp;&amp; __capacity &gt; __old_capacity)
<span class="lineNum">     571 </span>                :         {
<span class="lineNum">     572 </span>                :           const size_type __extra = __pagesize - __adj_size % __pagesize;
<span class="lineNum">     573 </span>                :           __capacity += __extra / sizeof(_CharT);
<span class="lineNum">     574 </span>                :           // Never allocate a string bigger than _S_max_size.
<span class="lineNum">     575 </span>                :           if (__capacity &gt; _S_max_size)
<span class="lineNum">     576 </span>                :             __capacity = _S_max_size;
<span class="lineNum">     577 </span>                :           __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
<span class="lineNum">     578 </span>                :         }
<span class="lineNum">     579 </span>                : 
<span class="lineNum">     580 </span>                :       // NB: Might throw, but no worries about a leak, mate: _Rep()
<span class="lineNum">     581 </span>                :       // does not throw.
<span class="lineNum">     582 </span>                :       void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
<span class="lineNum">     583 </span>                :       _Rep *__p = new (__place) _Rep;
<span class="lineNum">     584 </span>                :       __p-&gt;_M_capacity = __capacity;
<span class="lineNum">     585 </span>                :       // ABI compatibility - 3.4.x set in _S_create both
<span class="lineNum">     586 </span>                :       // _M_refcount and _M_length.  All callers of _S_create
<span class="lineNum">     587 </span>                :       // in basic_string.tcc then set just _M_length.
<span class="lineNum">     588 </span>                :       // In 4.0.x and later both _M_refcount and _M_length
<span class="lineNum">     589 </span>                :       // are initialized in the callers, unfortunately we can
<span class="lineNum">     590 </span>                :       // have 3.4.x compiled code with _S_create callers inlined
<span class="lineNum">     591 </span>                :       // calling 4.0.x+ _S_create.
<span class="lineNum">     592 </span>                :       __p-&gt;_M_set_sharable();
<span class="lineNum">     593 </span>                :       return __p;
<span class="lineNum">     594 </span>                :     }
<span class="lineNum">     595 </span>                : 
<span class="lineNum">     596 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     597 </span>                :     _CharT*
<span class="lineNum">     598 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::_Rep::
<span class="lineNum">     599 </span>                :     _M_clone(const _Alloc&amp; __alloc, size_type __res)
<span class="lineNum">     600 </span>                :     {
<span class="lineNum">     601 </span>                :       // Requested capacity of the clone.
<span class="lineNum">     602 </span>                :       const size_type __requested_cap = this-&gt;_M_length + __res;
<span class="lineNum">     603 </span>                :       _Rep* __r = _Rep::_S_create(__requested_cap, this-&gt;_M_capacity,
<span class="lineNum">     604 </span>                :                                   __alloc);
<span class="lineNum">     605 </span>                :       if (this-&gt;_M_length)
<span class="lineNum">     606 </span>                :         _M_copy(__r-&gt;_M_refdata(), _M_refdata(), this-&gt;_M_length);
<span class="lineNum">     607 </span>                : 
<span class="lineNum">     608 </span>                :       __r-&gt;_M_set_length_and_sharable(this-&gt;_M_length);
<span class="lineNum">     609 </span>                :       return __r-&gt;_M_refdata();
<span class="lineNum">     610 </span>                :     }
<span class="lineNum">     611 </span>                : 
<span class="lineNum">     612 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     613 </span>                :     void
<span class="lineNum">     614 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     615 </span>                :     resize(size_type __n, _CharT __c)
<span class="lineNum">     616 </span>                :     {
<span class="lineNum">     617 </span>                :       const size_type __size = this-&gt;size();
<span class="lineNum">     618 </span>                :       _M_check_length(__size, __n, &quot;basic_string::resize&quot;);
<span class="lineNum">     619 </span>                :       if (__size &lt; __n)
<span class="lineNum">     620 </span>                :         this-&gt;append(__n - __size, __c);
<span class="lineNum">     621 </span>                :       else if (__n &lt; __size)
<span class="lineNum">     622 </span>                :         this-&gt;erase(__n);
<span class="lineNum">     623 </span>                :       // else nothing (in particular, avoid calling _M_mutate() unnecessarily.)
<span class="lineNum">     624 </span>                :     }
<span class="lineNum">     625 </span>                : 
<span class="lineNum">     626 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     627 </span>                :     template&lt;typename _InputIterator&gt;
<span class="lineNum">     628 </span>                :       basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     629 </span>                :       basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     630 </span>                :       _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
<span class="lineNum">     631 </span>                :                           _InputIterator __k2, __false_type)
<span class="lineNum">     632 </span>                :       {
<span class="lineNum">     633 </span>                :         const basic_string __s(__k1, __k2);
<span class="lineNum">     634 </span>                :         const size_type __n1 = __i2 - __i1;
<span class="lineNum">     635 </span>                :         _M_check_length(__n1, __s.size(), &quot;basic_string::_M_replace_dispatch&quot;);
<span class="lineNum">     636 </span>                :         return _M_replace_safe(__i1 - _M_ibegin(), __n1, __s._M_data(),
<span class="lineNum">     637 </span>                :                                __s.size());
<span class="lineNum">     638 </span>                :       }
<span class="lineNum">     639 </span>                : 
<span class="lineNum">     640 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     641 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     642 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     643 </span>                :     _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
<span class="lineNum">     644 </span>                :                    _CharT __c)
<span class="lineNum">     645 </span>                :     {
<span class="lineNum">     646 </span>                :       _M_check_length(__n1, __n2, &quot;basic_string::_M_replace_aux&quot;);
<span class="lineNum">     647 </span>                :       _M_mutate(__pos1, __n1, __n2);
<span class="lineNum">     648 </span>                :       if (__n2)
<span class="lineNum">     649 </span>                :         _M_assign(_M_data() + __pos1, __n2, __c);
<span class="lineNum">     650 </span>                :       return *this;
<span class="lineNum">     651 </span>                :     }
<span class="lineNum">     652 </span>                : 
<span class="lineNum">     653 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     654 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;
<span class="lineNum">     655 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     656 </span>                :     _M_replace_safe(size_type __pos1, size_type __n1, const _CharT* __s,
<span class="lineNum">     657 </span>                :                     size_type __n2)
<span class="lineNum">     658 </span>                :     {
<span class="lineNum">     659 </span>                :       _M_mutate(__pos1, __n1, __n2);
<span class="lineNum">     660 </span>                :       if (__n2)
<span class="lineNum">     661 </span>                :         _M_copy(_M_data() + __pos1, __s, __n2);
<span class="lineNum">     662 </span>                :       return *this;
<span class="lineNum">     663 </span>                :     }
<span class="lineNum">     664 </span>                :    
<span class="lineNum">     665 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     666 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;
<span class="lineNum">     667 </span>                :     operator+(const _CharT* __lhs,
<span class="lineNum">     668 </span>                :               const basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __rhs)
<span class="lineNum">     669 </span>                :     {
<span class="lineNum">     670 </span>                :       __glibcxx_requires_string(__lhs);
<span class="lineNum">     671 </span>                :       typedef basic_string&lt;_CharT, _Traits, _Alloc&gt; __string_type;
<span class="lineNum">     672 </span>                :       typedef typename __string_type::size_type   __size_type;
<span class="lineNum">     673 </span>                :       const __size_type __len = _Traits::length(__lhs);
<span class="lineNum">     674 </span>                :       __string_type __str;
<span class="lineNum">     675 </span>                :       __str.reserve(__len + __rhs.size());
<span class="lineNum">     676 </span>                :       __str.append(__lhs, __len);
<span class="lineNum">     677 </span>                :       __str.append(__rhs);
<span class="lineNum">     678 </span>                :       return __str;
<span class="lineNum">     679 </span>                :     }
<span class="lineNum">     680 </span>                : 
<span class="lineNum">     681 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     682 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;
<span class="lineNum">     683 </span>                :     operator+(_CharT __lhs, const basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __rhs)
<span class="lineNum">     684 </span>                :     {
<span class="lineNum">     685 </span>                :       typedef basic_string&lt;_CharT, _Traits, _Alloc&gt; __string_type;
<span class="lineNum">     686 </span>                :       typedef typename __string_type::size_type   __size_type;
<span class="lineNum">     687 </span>                :       __string_type __str;
<span class="lineNum">     688 </span>                :       const __size_type __len = __rhs.size();
<span class="lineNum">     689 </span>                :       __str.reserve(__len + 1);
<span class="lineNum">     690 </span>                :       __str.append(__size_type(1), __lhs);
<span class="lineNum">     691 </span>                :       __str.append(__rhs);
<span class="lineNum">     692 </span>                :       return __str;
<span class="lineNum">     693 </span>                :     }
<span class="lineNum">     694 </span>                : 
<span class="lineNum">     695 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     696 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     697 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     698 </span>                :     copy(_CharT* __s, size_type __n, size_type __pos) const
<span class="lineNum">     699 </span>                :     {
<span class="lineNum">     700 </span>                :       _M_check(__pos, &quot;basic_string::copy&quot;);
<span class="lineNum">     701 </span>                :       __n = _M_limit(__pos, __n);
<span class="lineNum">     702 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     703 </span>                :       if (__n)
<span class="lineNum">     704 </span>                :         _M_copy(__s, _M_data() + __pos, __n);
<span class="lineNum">     705 </span>                :       // 21.3.5.7 par 3: do not append null.  (good.)
<span class="lineNum">     706 </span>                :       return __n;
<span class="lineNum">     707 </span>                :     }
<span class="lineNum">     708 </span>                : 
<span class="lineNum">     709 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     710 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     711 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     712 </span>                :     find(const _CharT* __s, size_type __pos, size_type __n) const
<span class="lineNum">     713 </span>                :     {
<span class="lineNum">     714 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     715 </span>                :       const size_type __size = this-&gt;size();
<span class="lineNum">     716 </span>                :       const _CharT* __data = _M_data();
<span class="lineNum">     717 </span>                : 
<span class="lineNum">     718 </span>                :       if (__n == 0)
<span class="lineNum">     719 </span>                :         return __pos &lt;= __size ? __pos : npos;
<span class="lineNum">     720 </span>                : 
<span class="lineNum">     721 </span>                :       if (__n &lt;= __size)
<span class="lineNum">     722 </span>                :         {
<span class="lineNum">     723 </span>                :           for (; __pos &lt;= __size - __n; ++__pos)
<span class="lineNum">     724 </span>                :             if (traits_type::eq(__data[__pos], __s[0])
<span class="lineNum">     725 </span>                :                 &amp;&amp; traits_type::compare(__data + __pos + 1,
<span class="lineNum">     726 </span>                :                                         __s + 1, __n - 1) == 0)
<span class="lineNum">     727 </span>                :               return __pos;
<span class="lineNum">     728 </span>                :         }
<span class="lineNum">     729 </span>                :       return npos;
<span class="lineNum">     730 </span>                :     }
<span class="lineNum">     731 </span>                : 
<span class="lineNum">     732 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     733 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     734 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     735 </span>                :     find(_CharT __c, size_type __pos) const
<span class="lineNum">     736 </span>                :     {
<span class="lineNum">     737 </span>                :       size_type __ret = npos;
<span class="lineNum">     738 </span>                :       const size_type __size = this-&gt;size();
<span class="lineNum">     739 </span>                :       if (__pos &lt; __size)
<span class="lineNum">     740 </span>                :         {
<span class="lineNum">     741 </span>                :           const _CharT* __data = _M_data();
<span class="lineNum">     742 </span>                :           const size_type __n = __size - __pos;
<span class="lineNum">     743 </span>                :           const _CharT* __p = traits_type::find(__data + __pos, __n, __c);
<span class="lineNum">     744 </span>                :           if (__p)
<span class="lineNum">     745 </span>                :             __ret = __p - __data;
<span class="lineNum">     746 </span>                :         }
<span class="lineNum">     747 </span>                :       return __ret;
<span class="lineNum">     748 </span>                :     }
<span class="lineNum">     749 </span>                : 
<span class="lineNum">     750 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     751 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     752 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     753 </span>                :     rfind(const _CharT* __s, size_type __pos, size_type __n) const
<span class="lineNum">     754 </span>                :     {
<span class="lineNum">     755 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     756 </span>                :       const size_type __size = this-&gt;size();
<span class="lineNum">     757 </span>                :       if (__n &lt;= __size)
<span class="lineNum">     758 </span>                :         {
<span class="lineNum">     759 </span>                :           __pos = std::min(size_type(__size - __n), __pos);
<span class="lineNum">     760 </span>                :           const _CharT* __data = _M_data();
<span class="lineNum">     761 </span>                :           do
<span class="lineNum">     762 </span>                :             {
<span class="lineNum">     763 </span>                :               if (traits_type::compare(__data + __pos, __s, __n) == 0)
<span class="lineNum">     764 </span>                :                 return __pos;
<span class="lineNum">     765 </span>                :             }
<span class="lineNum">     766 </span>                :           while (__pos-- &gt; 0);
<span class="lineNum">     767 </span>                :         }
<span class="lineNum">     768 </span>                :       return npos;
<span class="lineNum">     769 </span>                :     }
<span class="lineNum">     770 </span>                : 
<span class="lineNum">     771 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     772 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     773 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     774 </span>                :     rfind(_CharT __c, size_type __pos) const
<span class="lineNum">     775 </span>                :     {
<span class="lineNum">     776 </span>                :       size_type __size = this-&gt;size();
<span class="lineNum">     777 </span>                :       if (__size)
<span class="lineNum">     778 </span>                :         {
<span class="lineNum">     779 </span>                :           if (--__size &gt; __pos)
<span class="lineNum">     780 </span>                :             __size = __pos;
<span class="lineNum">     781 </span>                :           for (++__size; __size-- &gt; 0; )
<span class="lineNum">     782 </span>                :             if (traits_type::eq(_M_data()[__size], __c))
<span class="lineNum">     783 </span>                :               return __size;
<span class="lineNum">     784 </span>                :         }
<span class="lineNum">     785 </span>                :       return npos;
<span class="lineNum">     786 </span>                :     }
<span class="lineNum">     787 </span>                : 
<span class="lineNum">     788 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     789 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     790 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     791 </span>                :     find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
<span class="lineNum">     792 </span>                :     {
<span class="lineNum">     793 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     794 </span>                :       for (; __n &amp;&amp; __pos &lt; this-&gt;size(); ++__pos)
<span class="lineNum">     795 </span>                :         {
<span class="lineNum">     796 </span>                :           const _CharT* __p = traits_type::find(__s, __n, _M_data()[__pos]);
<span class="lineNum">     797 </span>                :           if (__p)
<span class="lineNum">     798 </span>                :             return __pos;
<span class="lineNum">     799 </span>                :         }
<span class="lineNum">     800 </span>                :       return npos;
<span class="lineNum">     801 </span>                :     }
<span class="lineNum">     802 </span>                : 
<span class="lineNum">     803 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     804 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     805 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     806 </span>                :     find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
<span class="lineNum">     807 </span>                :     {
<span class="lineNum">     808 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     809 </span>                :       size_type __size = this-&gt;size();
<span class="lineNum">     810 </span>                :       if (__size &amp;&amp; __n)
<span class="lineNum">     811 </span>                :         {
<span class="lineNum">     812 </span>                :           if (--__size &gt; __pos)
<span class="lineNum">     813 </span>                :             __size = __pos;
<span class="lineNum">     814 </span>                :           do
<span class="lineNum">     815 </span>                :             {
<span class="lineNum">     816 </span>                :               if (traits_type::find(__s, __n, _M_data()[__size]))
<span class="lineNum">     817 </span>                :                 return __size;
<span class="lineNum">     818 </span>                :             }
<span class="lineNum">     819 </span>                :           while (__size-- != 0);
<span class="lineNum">     820 </span>                :         }
<span class="lineNum">     821 </span>                :       return npos;
<span class="lineNum">     822 </span>                :     }
<span class="lineNum">     823 </span>                : 
<span class="lineNum">     824 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     825 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     826 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     827 </span>                :     find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
<span class="lineNum">     828 </span>                :     {
<span class="lineNum">     829 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     830 </span>                :       for (; __pos &lt; this-&gt;size(); ++__pos)
<span class="lineNum">     831 </span>                :         if (!traits_type::find(__s, __n, _M_data()[__pos]))
<span class="lineNum">     832 </span>                :           return __pos;
<span class="lineNum">     833 </span>                :       return npos;
<span class="lineNum">     834 </span>                :     }
<span class="lineNum">     835 </span>                : 
<span class="lineNum">     836 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     837 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     838 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     839 </span>                :     find_first_not_of(_CharT __c, size_type __pos) const
<span class="lineNum">     840 </span>                :     {
<span class="lineNum">     841 </span>                :       for (; __pos &lt; this-&gt;size(); ++__pos)
<span class="lineNum">     842 </span>                :         if (!traits_type::eq(_M_data()[__pos], __c))
<span class="lineNum">     843 </span>                :           return __pos;
<span class="lineNum">     844 </span>                :       return npos;
<span class="lineNum">     845 </span>                :     }
<span class="lineNum">     846 </span>                : 
<span class="lineNum">     847 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     848 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     849 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     850 </span>                :     find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
<span class="lineNum">     851 </span>                :     {
<span class="lineNum">     852 </span>                :       __glibcxx_requires_string_len(__s, __n);
<span class="lineNum">     853 </span>                :       size_type __size = this-&gt;size();
<span class="lineNum">     854 </span>                :       if (__size)
<span class="lineNum">     855 </span>                :         {
<span class="lineNum">     856 </span>                :           if (--__size &gt; __pos)
<span class="lineNum">     857 </span>                :             __size = __pos;
<span class="lineNum">     858 </span>                :           do
<span class="lineNum">     859 </span>                :             {
<span class="lineNum">     860 </span>                :               if (!traits_type::find(__s, __n, _M_data()[__size]))
<span class="lineNum">     861 </span>                :                 return __size;
<span class="lineNum">     862 </span>                :             }
<span class="lineNum">     863 </span>                :           while (__size--);
<span class="lineNum">     864 </span>                :         }
<span class="lineNum">     865 </span>                :       return npos;
<span class="lineNum">     866 </span>                :     }
<span class="lineNum">     867 </span>                : 
<span class="lineNum">     868 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     869 </span>                :     typename basic_string&lt;_CharT, _Traits, _Alloc&gt;::size_type
<span class="lineNum">     870 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     871 </span>                :     find_last_not_of(_CharT __c, size_type __pos) const
<span class="lineNum">     872 </span>                :     {
<span class="lineNum">     873 </span>                :       size_type __size = this-&gt;size();
<span class="lineNum">     874 </span>                :       if (__size)
<span class="lineNum">     875 </span>                :         {
<span class="lineNum">     876 </span>                :           if (--__size &gt; __pos)
<span class="lineNum">     877 </span>                :             __size = __pos;
<span class="lineNum">     878 </span>                :           do
<span class="lineNum">     879 </span>                :             {
<span class="lineNum">     880 </span>                :               if (!traits_type::eq(_M_data()[__size], __c))
<span class="lineNum">     881 </span>                :                 return __size;
<span class="lineNum">     882 </span>                :             }
<span class="lineNum">     883 </span>                :           while (__size--);
<span class="lineNum">     884 </span>                :         }
<span class="lineNum">     885 </span>                :       return npos;
<span class="lineNum">     886 </span>                :     }
<span class="lineNum">     887 </span>                : 
<span class="lineNum">     888 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     889 </span>                :     int
<span class="lineNum">     890 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     891 </span>                :     compare(size_type __pos, size_type __n, const basic_string&amp; __str) const
<span class="lineNum">     892 </span>                :     {
<span class="lineNum">     893 </span>                :       _M_check(__pos, &quot;basic_string::compare&quot;);
<span class="lineNum">     894 </span>                :       __n = _M_limit(__pos, __n);
<span class="lineNum">     895 </span>                :       const size_type __osize = __str.size();
<span class="lineNum">     896 </span>                :       const size_type __len = std::min(__n, __osize);
<span class="lineNum">     897 </span>                :       int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
<span class="lineNum">     898 </span>                :       if (!__r)
<span class="lineNum">     899 </span>                :         __r = _S_compare(__n, __osize);
<span class="lineNum">     900 </span>                :       return __r;
<span class="lineNum">     901 </span>                :     }
<span class="lineNum">     902 </span>                : 
<span class="lineNum">     903 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     904 </span>                :     int
<span class="lineNum">     905 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     906 </span>                :     compare(size_type __pos1, size_type __n1, const basic_string&amp; __str,
<span class="lineNum">     907 </span>                :             size_type __pos2, size_type __n2) const
<span class="lineNum">     908 </span>                :     {
<span class="lineNum">     909 </span>                :       _M_check(__pos1, &quot;basic_string::compare&quot;);
<span class="lineNum">     910 </span>                :       __str._M_check(__pos2, &quot;basic_string::compare&quot;);
<span class="lineNum">     911 </span>                :       __n1 = _M_limit(__pos1, __n1);
<span class="lineNum">     912 </span>                :       __n2 = __str._M_limit(__pos2, __n2);
<span class="lineNum">     913 </span>                :       const size_type __len = std::min(__n1, __n2);
<span class="lineNum">     914 </span>                :       int __r = traits_type::compare(_M_data() + __pos1,
<span class="lineNum">     915 </span>                :                                      __str.data() + __pos2, __len);
<span class="lineNum">     916 </span>                :       if (!__r)
<span class="lineNum">     917 </span>                :         __r = _S_compare(__n1, __n2);
<span class="lineNum">     918 </span>                :       return __r;
<span class="lineNum">     919 </span>                :     }
<span class="lineNum">     920 </span>                : 
<span class="lineNum">     921 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     922 </span>                :     int
<span class="lineNum">     923 </span>                :     basic_string&lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     924 </span>                :     compare(const _CharT* __s) const
<span class="lineNum">     925 </span>                :     {
<span class="lineNum">     926 </span>                :       __glibcxx_requires_string(__s);
<span class="lineNum">     927 </span>                :       const size_type __size = this-&gt;size();
<span class="lineNum">     928 </span>                :       const size_type __osize = traits_type::length(__s);
<span class="lineNum">     929 </span>                :       const size_type __len = std::min(__size, __osize);
<span class="lineNum">     930 </span>                :       int __r = traits_type::compare(_M_data(), __s, __len);
<span class="lineNum">     931 </span>                :       if (!__r)
<span class="lineNum">     932 </span>                :         __r = _S_compare(__size, __osize);
<span class="lineNum">     933 </span>                :       return __r;
<span class="lineNum">     934 </span>                :     }
<span class="lineNum">     935 </span>                : 
<span class="lineNum">     936 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     937 </span>                :     int
<span class="lineNum">     938 </span>                :     basic_string &lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     939 </span>                :     compare(size_type __pos, size_type __n1, const _CharT* __s) const
<span class="lineNum">     940 </span>                :     {
<span class="lineNum">     941 </span>                :       __glibcxx_requires_string(__s);
<span class="lineNum">     942 </span>                :       _M_check(__pos, &quot;basic_string::compare&quot;);
<span class="lineNum">     943 </span>                :       __n1 = _M_limit(__pos, __n1);
<span class="lineNum">     944 </span>                :       const size_type __osize = traits_type::length(__s);
<span class="lineNum">     945 </span>                :       const size_type __len = std::min(__n1, __osize);
<span class="lineNum">     946 </span>                :       int __r = traits_type::compare(_M_data() + __pos, __s, __len);
<span class="lineNum">     947 </span>                :       if (!__r)
<span class="lineNum">     948 </span>                :         __r = _S_compare(__n1, __osize);
<span class="lineNum">     949 </span>                :       return __r;
<span class="lineNum">     950 </span>                :     }
<span class="lineNum">     951 </span>                : 
<span class="lineNum">     952 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     953 </span>                :     int
<span class="lineNum">     954 </span>                :     basic_string &lt;_CharT, _Traits, _Alloc&gt;::
<span class="lineNum">     955 </span>                :     compare(size_type __pos, size_type __n1, const _CharT* __s,
<span class="lineNum">     956 </span>                :             size_type __n2) const
<span class="lineNum">     957 </span>                :     {
<span class="lineNum">     958 </span>                :       __glibcxx_requires_string_len(__s, __n2);
<span class="lineNum">     959 </span>                :       _M_check(__pos, &quot;basic_string::compare&quot;);
<span class="lineNum">     960 </span>                :       __n1 = _M_limit(__pos, __n1);
<span class="lineNum">     961 </span>                :       const size_type __len = std::min(__n1, __n2);
<span class="lineNum">     962 </span>                :       int __r = traits_type::compare(_M_data() + __pos, __s, __len);
<span class="lineNum">     963 </span>                :       if (!__r)
<span class="lineNum">     964 </span>                :         __r = _S_compare(__n1, __n2);
<span class="lineNum">     965 </span>                :       return __r;
<span class="lineNum">     966 </span>                :     }
<span class="lineNum">     967 </span>                : 
<span class="lineNum">     968 </span>                :   // 21.3.7.9 basic_string::getline and operators
<span class="lineNum">     969 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">     970 </span>                :     basic_istream&lt;_CharT, _Traits&gt;&amp;
<span class="lineNum">     971 </span>                :     operator&gt;&gt;(basic_istream&lt;_CharT, _Traits&gt;&amp; __in,
<span class="lineNum">     972 </span>                :                basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __str)
<span class="lineNum">     973 </span>                :     {
<span class="lineNum">     974 </span>                :       typedef basic_istream&lt;_CharT, _Traits&gt;              __istream_type;
<span class="lineNum">     975 </span>                :       typedef basic_string&lt;_CharT, _Traits, _Alloc&gt;       __string_type;
<span class="lineNum">     976 </span>                :       typedef typename __istream_type::ios_base         __ios_base;
<span class="lineNum">     977 </span>                :       typedef typename __istream_type::int_type         __int_type;
<span class="lineNum">     978 </span>                :       typedef typename __string_type::size_type         __size_type;
<span class="lineNum">     979 </span>                :       typedef ctype&lt;_CharT&gt;                               __ctype_type;
<span class="lineNum">     980 </span>                :       typedef typename __ctype_type::ctype_base         __ctype_base;
<span class="lineNum">     981 </span>                : 
<span class="lineNum">     982 </span>                :       __size_type __extracted = 0;
<span class="lineNum">     983 </span>                :       typename __ios_base::iostate __err = __ios_base::goodbit;
<span class="lineNum">     984 </span>                :       typename __istream_type::sentry __cerb(__in, false);
<span class="lineNum">     985 </span>                :       if (__cerb)
<span class="lineNum">     986 </span>                :         {
<span class="lineNum">     987 </span>                :           try
<span class="lineNum">     988 </span>                :             {
<span class="lineNum">     989 </span>                :               // Avoid reallocation for common case.
<span class="lineNum">     990 </span>                :               __str.erase();
<span class="lineNum">     991 </span>                :               _CharT __buf[128];
<span class="lineNum">     992 </span>                :               __size_type __len = 0;          
<span class="lineNum">     993 </span>                :               const streamsize __w = __in.width();
<span class="lineNum">     994 </span>                :               const __size_type __n = __w &gt; 0 ? static_cast&lt;__size_type&gt;(__w)
<span class="lineNum">     995 </span>                :                                               : __str.max_size();
<span class="lineNum">     996 </span>                :               const __ctype_type&amp; __ct = use_facet&lt;__ctype_type&gt;(__in.getloc());
<span class="lineNum">     997 </span>                :               const __int_type __eof = _Traits::eof();
<span class="lineNum">     998 </span>                :               __int_type __c = __in.rdbuf()-&gt;sgetc();
<span class="lineNum">     999 </span>                : 
<span class="lineNum">    1000 </span>                :               while (__extracted &lt; __n
<span class="lineNum">    1001 </span>                :                      &amp;&amp; !_Traits::eq_int_type(__c, __eof)
<span class="lineNum">    1002 </span>                :                      &amp;&amp; !__ct.is(__ctype_base::space,
<span class="lineNum">    1003 </span>                :                                  _Traits::to_char_type(__c)))
<span class="lineNum">    1004 </span>                :                 {
<span class="lineNum">    1005 </span>                :                   if (__len == sizeof(__buf) / sizeof(_CharT))
<span class="lineNum">    1006 </span>                :                     {
<span class="lineNum">    1007 </span>                :                       __str.append(__buf, sizeof(__buf) / sizeof(_CharT));
<span class="lineNum">    1008 </span>                :                       __len = 0;
<span class="lineNum">    1009 </span>                :                     }
<span class="lineNum">    1010 </span>                :                   __buf[__len++] = _Traits::to_char_type(__c);
<span class="lineNum">    1011 </span>                :                   ++__extracted;
<span class="lineNum">    1012 </span>                :                   __c = __in.rdbuf()-&gt;snextc();
<span class="lineNum">    1013 </span>                :                 }
<span class="lineNum">    1014 </span>                :               __str.append(__buf, __len);
<span class="lineNum">    1015 </span>                : 
<span class="lineNum">    1016 </span>                :               if (_Traits::eq_int_type(__c, __eof))
<span class="lineNum">    1017 </span>                :                 __err |= __ios_base::eofbit;
<span class="lineNum">    1018 </span>                :               __in.width(0);
<span class="lineNum">    1019 </span>                :             }
<span class="lineNum">    1020 </span>                :           catch(__cxxabiv1::__forced_unwind&amp;)
<span class="lineNum">    1021 </span>                :             {
<span class="lineNum">    1022 </span>                :               __in._M_setstate(__ios_base::badbit);
<span class="lineNum">    1023 </span>                :               __throw_exception_again;
<span class="lineNum">    1024 </span>                :             }
<span class="lineNum">    1025 </span>                :           catch(...)
<span class="lineNum">    1026 </span>                :             {
<span class="lineNum">    1027 </span>                :               // _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    1028 </span>                :               // 91. Description of operator&gt;&gt; and getline() for string&lt;&gt;
<span class="lineNum">    1029 </span>                :               // might cause endless loop
<span class="lineNum">    1030 </span>                :               __in._M_setstate(__ios_base::badbit);
<span class="lineNum">    1031 </span>                :             }
<span class="lineNum">    1032 </span>                :         }
<span class="lineNum">    1033 </span>                :       // 211.  operator&gt;&gt;(istream&amp;, string&amp;) doesn't set failbit
<span class="lineNum">    1034 </span>                :       if (!__extracted)
<span class="lineNum">    1035 </span>                :         __err |= __ios_base::failbit;
<span class="lineNum">    1036 </span>                :       if (__err)
<span class="lineNum">    1037 </span>                :         __in.setstate(__err);
<span class="lineNum">    1038 </span>                :       return __in;
<span class="lineNum">    1039 </span>                :     }
<span class="lineNum">    1040 </span>                : 
<span class="lineNum">    1041 </span>                :   template&lt;typename _CharT, typename _Traits, typename _Alloc&gt;
<span class="lineNum">    1042 </span>                :     basic_istream&lt;_CharT, _Traits&gt;&amp;
<span class="lineNum">    1043 </span>                :     getline(basic_istream&lt;_CharT, _Traits&gt;&amp; __in,
<span class="lineNum">    1044 </span>                :             basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp; __str, _CharT __delim)
<span class="lineNum">    1045 </span>                :     {
<span class="lineNum">    1046 </span>                :       typedef basic_istream&lt;_CharT, _Traits&gt;              __istream_type;
<span class="lineNum">    1047 </span>                :       typedef basic_string&lt;_CharT, _Traits, _Alloc&gt;       __string_type;
<span class="lineNum">    1048 </span>                :       typedef typename __istream_type::ios_base         __ios_base;
<span class="lineNum">    1049 </span>                :       typedef typename __istream_type::int_type         __int_type;
<span class="lineNum">    1050 </span>                :       typedef typename __string_type::size_type         __size_type;
<span class="lineNum">    1051 </span>                : 
<span class="lineNum">    1052 </span>                :       __size_type __extracted = 0;
<span class="lineNum">    1053 </span>                :       const __size_type __n = __str.max_size();
<span class="lineNum">    1054 </span>                :       typename __ios_base::iostate __err = __ios_base::goodbit;
<span class="lineNum">    1055 </span>                :       typename __istream_type::sentry __cerb(__in, true);
<span class="lineNum">    1056 </span>                :       if (__cerb)
<span class="lineNum">    1057 </span>                :         {
<span class="lineNum">    1058 </span>                :           try
<span class="lineNum">    1059 </span>                :             {
<span class="lineNum">    1060 </span>                :               __str.erase();
<span class="lineNum">    1061 </span>                :               const __int_type __idelim = _Traits::to_int_type(__delim);
<span class="lineNum">    1062 </span>                :               const __int_type __eof = _Traits::eof();
<span class="lineNum">    1063 </span>                :               __int_type __c = __in.rdbuf()-&gt;sgetc();
<span class="lineNum">    1064 </span>                : 
<span class="lineNum">    1065 </span>                :               while (__extracted &lt; __n
<span class="lineNum">    1066 </span>                :                      &amp;&amp; !_Traits::eq_int_type(__c, __eof)
<span class="lineNum">    1067 </span>                :                      &amp;&amp; !_Traits::eq_int_type(__c, __idelim))
<span class="lineNum">    1068 </span>                :                 {
<span class="lineNum">    1069 </span>                :                   __str += _Traits::to_char_type(__c);
<span class="lineNum">    1070 </span>                :                   ++__extracted;
<span class="lineNum">    1071 </span>                :                   __c = __in.rdbuf()-&gt;snextc();
<span class="lineNum">    1072 </span>                :                 }
<span class="lineNum">    1073 </span>                : 
<span class="lineNum">    1074 </span>                :               if (_Traits::eq_int_type(__c, __eof))
<span class="lineNum">    1075 </span>                :                 __err |= __ios_base::eofbit;
<span class="lineNum">    1076 </span>                :               else if (_Traits::eq_int_type(__c, __idelim))
<span class="lineNum">    1077 </span>                :                 {
<span class="lineNum">    1078 </span>                :                   ++__extracted;                  
<span class="lineNum">    1079 </span>                :                   __in.rdbuf()-&gt;sbumpc();
<span class="lineNum">    1080 </span>                :                 }
<span class="lineNum">    1081 </span>                :               else
<span class="lineNum">    1082 </span>                :                 __err |= __ios_base::failbit;
<span class="lineNum">    1083 </span>                :             }
<span class="lineNum">    1084 </span>                :           catch(__cxxabiv1::__forced_unwind&amp;)
<span class="lineNum">    1085 </span>                :             {
<span class="lineNum">    1086 </span>                :               __in._M_setstate(__ios_base::badbit);
<span class="lineNum">    1087 </span>                :               __throw_exception_again;
<span class="lineNum">    1088 </span>                :             }
<span class="lineNum">    1089 </span>                :           catch(...)
<span class="lineNum">    1090 </span>                :             {
<span class="lineNum">    1091 </span>                :               // _GLIBCXX_RESOLVE_LIB_DEFECTS
<span class="lineNum">    1092 </span>                :               // 91. Description of operator&gt;&gt; and getline() for string&lt;&gt;
<span class="lineNum">    1093 </span>                :               // might cause endless loop
<span class="lineNum">    1094 </span>                :               __in._M_setstate(__ios_base::badbit);
<span class="lineNum">    1095 </span>                :             }
<span class="lineNum">    1096 </span>                :         }
<span class="lineNum">    1097 </span>                :       if (!__extracted)
<span class="lineNum">    1098 </span>                :         __err |= __ios_base::failbit;
<span class="lineNum">    1099 </span>                :       if (__err)
<span class="lineNum">    1100 </span>                :         __in.setstate(__err);
<span class="lineNum">    1101 </span>                :       return __in;
<span class="lineNum">    1102 </span>                :     }
<span class="lineNum">    1103 </span>                : 
<span class="lineNum">    1104 </span>                :   // Inhibit implicit instantiations for required instantiations,
<span class="lineNum">    1105 </span>                :   // which are defined via explicit instantiations elsewhere.
<span class="lineNum">    1106 </span>                :   // NB: This syntax is a GNU extension.
<span class="lineNum">    1107 </span>                : #if _GLIBCXX_EXTERN_TEMPLATE
<span class="lineNum">    1108 </span>                :   extern template class basic_string&lt;char&gt;;
<span class="lineNum">    1109 </span>                :   extern template
<span class="lineNum">    1110 </span>                :     basic_istream&lt;char&gt;&amp;
<span class="lineNum">    1111 </span>                :     operator&gt;&gt;(basic_istream&lt;char&gt;&amp;, string&amp;);
<span class="lineNum">    1112 </span>                :   extern template
<span class="lineNum">    1113 </span>                :     basic_ostream&lt;char&gt;&amp;
<span class="lineNum">    1114 </span>                :     operator&lt;&lt;(basic_ostream&lt;char&gt;&amp;, const string&amp;);
<span class="lineNum">    1115 </span>                :   extern template
<span class="lineNum">    1116 </span>                :     basic_istream&lt;char&gt;&amp;
<span class="lineNum">    1117 </span>                :     getline(basic_istream&lt;char&gt;&amp;, string&amp;, char);
<span class="lineNum">    1118 </span>                :   extern template
<span class="lineNum">    1119 </span>                :     basic_istream&lt;char&gt;&amp;
<span class="lineNum">    1120 </span>                :     getline(basic_istream&lt;char&gt;&amp;, string&amp;);
<span class="lineNum">    1121 </span>                : 
<span class="lineNum">    1122 </span>                : #ifdef _GLIBCXX_USE_WCHAR_T
<span class="lineNum">    1123 </span>                :   extern template class basic_string&lt;wchar_t&gt;;
<span class="lineNum">    1124 </span>                :   extern template
<span class="lineNum">    1125 </span>                :     basic_istream&lt;wchar_t&gt;&amp;
<span class="lineNum">    1126 </span>                :     operator&gt;&gt;(basic_istream&lt;wchar_t&gt;&amp;, wstring&amp;);
<span class="lineNum">    1127 </span>                :   extern template
<span class="lineNum">    1128 </span>                :     basic_ostream&lt;wchar_t&gt;&amp;
<span class="lineNum">    1129 </span>                :     operator&lt;&lt;(basic_ostream&lt;wchar_t&gt;&amp;, const wstring&amp;);
<span class="lineNum">    1130 </span>                :   extern template
<span class="lineNum">    1131 </span>                :     basic_istream&lt;wchar_t&gt;&amp;
<span class="lineNum">    1132 </span>                :     getline(basic_istream&lt;wchar_t&gt;&amp;, wstring&amp;, wchar_t);
<span class="lineNum">    1133 </span>                :   extern template
<span class="lineNum">    1134 </span>                :     basic_istream&lt;wchar_t&gt;&amp;
<span class="lineNum">    1135 </span>                :     getline(basic_istream&lt;wchar_t&gt;&amp;, wstring&amp;);
<span class="lineNum">    1136 </span>                : #endif
<span class="lineNum">    1137 </span>                : #endif
<span class="lineNum">    1138 </span>                : 
<span class="lineNum">    1139 </span>                : _GLIBCXX_END_NAMESPACE
<span class="lineNum">    1140 </span>                : 
<span class="lineNum">    1141 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
